<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>
<style>
    .public {
        width: 100px;
        height: 100px;
    }

    .active {
        background: red;
    }

    .noActive {
        background-color: yellowgreen;
    }

    .red {
        color: red;
    }

    .pink {
        color: pink
    }

    .bold {
        font-weight: bold;
    }

    .italic {
        font-style: italic;
    }
</style>

<body>
    <!-- 创建容器 -->
    <div id="app">
        <div class="public" :class="isActive?'active':'noActive'">box1</div>
        <!-- v-bind 添加class属性时,若重复添加,则以第一个为准 -->
        <div class="public" :class="fontColor" :class="boxClass">box2</div>
        <div class="public" :class="classArr">box3</div>
    </div>
    <script>
        Vue.config.peoductionTip = false
        //实例化一个vm,Vue是MVVM模型中的核心
        //Vue是一个构造函数 使用时需实例化
        const vm = new Vue({
            // el:string | selector
            el: "#app",
            // data:Object|function
            data() {
                return {
                    isActive: true,
                    fontColor: "pink",
                    boxClass: {
                        red: true,
                        bold: true,
                        italic: true,
                    },
                    isRed: true,
                    isBold: true,
                    isItalic: true,
                    classArr: ["red", "italic"]
                }
            }
        })

    </script>
</body>

</html>